package com.example.eliminateifelse.designmode;

import com.example.eliminateifelse.entity.Item;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service(value = "VipUserCart")
public class VipUserCart extends NormalUserCart {  

    @Override  
    protected void processCouponPrice(long userId, Item item) {
        if (item.getQuantity() > 2) {  
            item.setCouponPrice(item.getPrice()  
                                .multiply(BigDecimal.valueOf(100 - userId).divide(new BigDecimal("100")))
                                .multiply(BigDecimal.valueOf(item.getQuantity() - 2)));
        } else {  
            item.setCouponPrice(BigDecimal.ZERO);  
        }  
    }  
}  